package com.bdjk.bdmw.InfoGath.communication.server.tcp.socket;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.OutputStream;
import java.io.StringReader;
import java.net.Socket;


/**
 * @author hy
 *
 */
public class ServerOutputThread extends Thread {
	private Socket socket;

	public ServerOutputThread(Socket socket) {
		super();
		this.socket = socket;
	}

	@Override
	public void run() {
		try {

			OutputStream os = socket.getOutputStream();

			while (true) {
				BufferedReader reader = new BufferedReader(new StringReader(this.getName() + "-----ceshi-----"));

				String line = reader.readLine();

				os.write(line.getBytes());
				Thread.sleep(1000);
			}
		} catch (IOException e) {
			e.printStackTrace();
		} catch (InterruptedException e){
			e.printStackTrace();
		}

	}

}
